package com.example.spareparts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.spareparts.entity.InBoundRecords;
import com.example.spareparts.service.InBoundRecordsService;
import java.util.List;

@RestController
@RequestMapping("/api/inboundrecords")
public class InBoundRecordsController {
    @Autowired
    private InBoundRecordsService inBoundRecordsService;
    @GetMapping ("/listall")
    public List<InBoundRecords> findAllInBoundRecords(){
        return inBoundRecordsService.findAllInBoundRecords();
    }
    @PostMapping ("/insert")
    public void insertInBoundRecord(@RequestBody InBoundRecords inBoundRecord){
        inBoundRecordsService.insertInBoundRecord(inBoundRecord);
    }
    @PutMapping ("/update/{inboundid}")
    public void updateInBoundRecord(@PathVariable Long inboundid, @RequestBody InBoundRecords inBoundRecord){
        inBoundRecord.setInboundid(inboundid);
        inBoundRecordsService.updateInBoundRecord(inBoundRecord);
    }
    @DeleteMapping ("/delete/{inboundid}")
    public void deleteInBoundRecord(@PathVariable Long inboundid){
        inBoundRecordsService.deleteInBoundRecord(inboundid);
    }
    @GetMapping ("/findbyid/{inboundid}")
    public InBoundRecords findInBoundRecordById(@PathVariable Long inboundid){
        return inBoundRecordsService.findInBoundRecordById(inboundid);
    }
    @GetMapping ("/findbysparepartid/{sparepartid}")
    public List<InBoundRecords> findInBoundRecordBySparePartId(@PathVariable Long sparepartid){
        return inBoundRecordsService.findInBoundRecordBySparePartId(sparepartid);
    }
    @GetMapping ("/findbybatchnumber/{batchNumber}")
    public InBoundRecords findInBoundRecordByBatchNumber(@PathVariable String batchNumber){
        return inBoundRecordsService.findInBoundRecordByBatchNumber(batchNumber);
    }

}
